<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{time | timeFormat}}
    </div>
    <script src="./todomvc-app-template-master/node_modules/vue/dist/vue.js"></script>
    <script>
        // 1.全局过滤器
        // Vue.filter("timeFormat", (val)=> {
        //     let time = new Date(val)
        //     let year = time.getFullYear()
        //     let month = time.getMonth() + 1
        //     let day = time.getDate();
        //     return year + "年" + month + "月" + day + "号"
        // })
        const app = new Vue({
            el: "#app",
            data: {
                // 2022年2月16号
                time: "2022-02-16"
            },
            filters: {
                timeFormat(val) {
                    let time = new Date(val)
                    let year = time.getFullYear()
                    let month = time.getMonth() + 1
                    let day = time.getDate();
                    return year + "年" + month + "月" + day + "号"
                }
            }
        })
    </script>
</body>
</html>